package leetcode.L76;

import java.util.HashMap;
import java.util.Map;

class Solution {

    Map<Character, Integer> source = new HashMap<>();
    Map<Character, Integer> target = new HashMap<>();

    public String minWindow(String s, String t) {
        if (s == null || t == null || s.isEmpty() || t.isEmpty() || s.length() < t.length()) return "";
        for (int i = 0; i < t.length(); i++) {
            char c = t.charAt(i);
            source.put(c, source.getOrDefault(c, 0) + 1);
        }
        int len = Integer.MAX_VALUE;
        int left = 0, right = 0;
        while (left <= right && right < s.length()) {
            char c = s.charAt(right);
            source.put(c, source.getOrDefault(c, 0) + 1);
            while (check()&&left<=right) {
                if (right - left + 1 < len) {

                }
            }
        }


        return "";
    }

    private boolean check() {
        for (Map.Entry<Character, Integer> entry : source.entrySet()) {
            Character c = entry.getKey();
            Integer v = entry.getValue();
            if (target.getOrDefault(c, 0) > v) {
                return false;
            }
        }
        return true;
    }
}